<%@page import="javax.persistence.Persistence"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page import="model.UserJpaController"%>
<%@page import="model.User"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="beans.Group"%>
        
        
<%
//    1)<jsp:useBean id="userId" class="java.lang.String" scope="request" />
//    <jsp:useBean id="name" class="java.lang.String" scope="request" />
//        <jsp:useBean id="surname" class="java.lang.String" scope="request" />
//        <jsp:useBean id="grp" class="java.lang.String" scope="request" />
//        <jsp:useBean id="imagePath" class="java.lang.String" scope="request" />
        
//        if (userId == null || name == null || surname == null || grp == null) {
//            response.sendRedirect("index.jsp");
//        }
        HttpSession ses = request.getSession();
        String user1 =(String)ses.getAttribute("userId");

        Group group = new Group();
        //2)group.setUserId(Integer.parseInt(userId));
        group.setUserId(Integer.parseInt(user1));
        
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("WebApplication1PU");
        EntityManager em = emf.createEntityManager();
        UserJpaController control = new UserJpaController(emf);
        
        //3)User user = control.findUser(Integer.parseInt(userId));
        User user = control.findUser(Integer.parseInt(user1));
        System.out.println(user.getName());
        ArrayList<String> list = group.getSubjects(); 
    %>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Education | Home</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="default.css" rel="stylesheet" type="text/css" />
    
</head>
<body>
    
    
    
    <div id="header">
            
        <div id="logo">
            <h1><a href="#">Newfangled</a></h1>
            <h2><a href="http://www.freecsstemplates.org/">By Free CSS Templates</a></h2>
        </div>
        <div id="menu">
            <ul>
                <li class="active"><a href="#" title="">Homepage</a></li>
                <li><a href="#" title="">About Us</a></li>
                <li><a href="#" title="">Products</a></li>
                <li><a href="#" title="">Clients</a></li>
                <li><a href="Logout" title="">LogOut</a></li>
                
            </ul>
        </div>
    </div>
    <div id="content">
        <div id="sidebar">
            <div id="login" class="boxed">
                <div class="title">
                    <h2>Student</h2>
                </div>
                <div class="content">
                    <form id="form1" method="post" action="#">
                        <table cellspacing=2">
                            <tr>
                                <td>
                                    <img src="images/<%=user.getImagePath()%>" width="100" height="100" alt="avatar"/>
                                </td>
                                <td >
                                    <p><a href="#"><%=user.getName() + " " + user.getSurname()%></a></p>
                                    <label for="inputtext2"><%=user.getGrp()%></label>
                                </td>
                            </tr>
                        </table>
                    </form>

                </div>
            </div>
            <!-- end #login -->

            <div id="updates" class="boxed">
                <div class="title">
                    <h2>Groups</h2>
                </div>
                <div class="content">
                    <ul>
                        <%
                        for(String s:list){
                            %>
                                            <li> <a href="#"><%=s%></a></li>
                                            <%
                        }
                        %>
                    </ul>
                </div>
            </div>
            <!-- end #updates -->
        </div>
        <!-- end #sidebar -->
        <div id="main">
            <div id="welcome" class="post">
                <h2 class="title"><span>Latest Posts!</span></h2>
                
                <h3 class="date"><span class="month">Mar.</span> <span class="day">8</span><span class="year">, 2007</span></h3>
                
                <div class="story"><img src="images/img09.jpg" alt="" width="80" height="80" class="left" />
                    
                    <p><strong>Aslan</strong> to <a href="#">Test</a> 
                        Released under a <a href="http://creativecommons.org/licenses/by/2.5/">Creative Commons Attribution 2.5 License</a>. 
                        The photo is from <a href="http://www.pdphoto.org/">PDPhoto.org</a>. 
                        You're free to use it for both commercial or personal use. I only ask that you link back to my site in some way. 
                        <em>Enjoy :)</em></p>
                </div>
                <div class="meta">
                    <p>Posted by Jane Anderson under <a href="#">Uncategorized</a>, <a href="#">Daily Journal</a><br />
                        <a href="#">Trackback URI</a> | <a href="#">No Comments</a> | <a href="#">Permalink</a></p>
                </div>
            </div>
            <!-- end #welcome -->
            <div id="example" class="post">
                <h2 class="title"><span>Examples of Common Tags</span></h2>
                <h3 class="date"><span class="month">Feb.</span> <span class="day">24</span><span class="year">, 2007</span></h3>
                <div class="story">
                    <p>This is an example of a paragraph followed by a blockquote:</p>
                    <blockquote>
                        <p>&ldquo;Pellentesque tristique ante ut  risus. Quisque dictum. Integer nisl risus, sagittis convallis, rutrum  id, elementum congue, nibh. Suspendisse dictum porta lectus. Donec  placerat odio.&rdquo;</p>
                    </blockquote>
                    <h3>Heading Level Three</h3>
                    <p>This is another example of a paragraph followed by an unordered list:</p>
                    <p>An ordered list example:</p>
                    <ol>
                        <li>List item number one</li>
                        <li>List item number two</li>
                        <li>List item number thre</li>
                    </ol>
                </div>
                <div class="meta">
                    <p>Posted by Jane Anderson under <a href="#">Samples</a><br />
                        <a href="#">Trackback URI</a> | <a href="#">No Comments</a> | <a href="#">Permalink</a></p>
                </div>
            </div>
            <!-- end #example -->
        </div>
        <!-- end #main -->
        <div id="sidebar2">
            <div id="sponsors" class="boxed">
                <div class="title">
                    <h2>Sponsors</h2>
                </div>
                <div class="content">
                    <ul>
                        <li> <a href="#">In posuere eleifend</a></li>
                        <li> <a href="#">Quisque dictum </a></li>
                        <li> <a href="#">Donec leo, vivamus </a></li>
                        <li> <a href="#">Nam pede erat porta </a></li>
                        <li> <a href="#">Vivamus fermentum </a></li>
                    </ul>
                </div>
            </div>
            <!-- end #sponsors -->
            <div id="ad120x600"><a href="#"><img src="images/ad_120x600.jpg" alt="" width="120" height="600" /></a></div>
        </div>
        <div style="clear: both;">&nbsp;</div>
    </div>
    <!-- end #sidebar2 -->
    <!-- end #content -->
    <div id="footer">
        <p id="legal">Copyright &copy; 2007 Newfangled. All Rights Reserved. Designed by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a> | <a href="http://www.maadesigns.co.uk/">Design</a> downloaded from&nbsp;DH <a href="http://webtemplates.dezinehub.com">Website Templates</a></p>
        <p id="links"><a href="#">Privacy Policy</a> | <a href="#">Terms of Use</a></p>
    </div>
</body>
</html>
